package com.example.day05.homework;

import java.util.Date;

public class HourlyEmployee  extends  Employee{
    private  int hours;
    private   double salary;

    public HourlyEmployee(String name, Date birthday, int hours, double salary) {
        super(name, birthday);
        this.hours = hours;
        this.salary = salary;
    }


    public int getHours() {
        return hours;
    }

    public void setHours(int hours) {
        this.hours = hours;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public double getSalary(int month) {
        if(this.getHours()>160) {
            if (this.getBirthday().getMonth() == month) {
                this.setSalary(((160* this.getSalary())+(this.getHours()-160)*this.getSalary()*1.5) + 100);
            } else {
                this.setSalary(((160* this.getSalary())+(this.getHours()-160)*this.getSalary()*1.5));
            }
        }
        if (this.getHours()<160){
            if (this.getBirthday().getMonth() == month) {
                this.setSalary(this.getHours() * this.getSalary() + 100);
            } else {
                this.setSalary(this.getHours() * this.getSalary());
            }
        }
        return this.getSalary() ;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("HourlyEmployee{");
        super.toString();
        sb.append("hours=").append(hours);
        sb.append(", salary=").append(salary);
        sb.append('}');
        return sb.toString();
    }
}
